package com.itheima.convert;


import com.itheima.dto.NoticeDto;
import com.itheima.dto.UpdateNoticeDto;
import com.itheima.entity.Notice;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.time.LocalDateTime;

/**
 * <h1>Notice转换接口</h1>
 *
 * @author <a href="515857087@qq.com">叶世铭</a>
 * @since 2022/12/3
 */
@Mapper(componentModel="spring")
public interface NoticeConvert {

    /**
     * NoticeDto -> Notice
     * @param noticeDto
     * @param userId
     * @param now
     * @return
     */
    @Mapping(target = "createdAt" ,source = "now")
    @Mapping(target = "userId",source = "userId")
    Notice noticeDtoToNotice(NoticeDto noticeDto,String userId, LocalDateTime now);


    /**
     * Notice -> NoticeDto
     * @param notice
     * @param operation
     * @return
     */
    @Mapping(target = "operation",source = "operation")
    NoticeDto noticeToNoticeDto(Notice notice,String operation);

    /**
     * UpdateNoticeDto -> Notice
     * @param updateNoticeDto
     * @param userId
     * @return
     */
    Notice updateNoticeDtoToNotice(UpdateNoticeDto updateNoticeDto,String userId);

}
